//
//  TravelTableCell.m
//  MiaoTu
//
//  Created by dllo on 16/9/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TravelTableCell.h"
#import "UIImageView+WebCache.h"
#import "TravelItem.h"
#import "Piclist.h"
#import "NSDate+CompareDate.h"
#import "AssemblingPlaceView.h"
#import "Assemblingplace.h"
#import "MyLocation.h"
#import "UIView+Frame.h"
#import "ZWYNetTool.h"
#import "LikeModel.h"
#import "LikeItem.h"
#import "LikeAndReplyButton.h"

@interface TravelTableCell ()
@property (nonatomic, strong) UIImageView *headImage;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UIImageView *genderImage;
@property (nonatomic, strong) UILabel *ageLabel;
@property (nonatomic, strong) UILabel *timeAndRangeLabel;
@property (nonatomic, strong) UILabel *remarkLabel;
@property (nonatomic, strong) UILabel *destinationLabel;
@property (nonatomic, strong) UILabel *requireLabel;
@property (nonatomic, strong) UILabel *moneyTypeLabel;
@property (nonatomic, strong) UIImageView *destinationDotImage;
@property (nonatomic, strong) UIImageView *requireDotImage;
@property (nonatomic, strong) UIImageView *moneyDotImage;
@property (nonatomic, strong) UIImageView *leftImageView;
@property (nonatomic, strong) UIImageView *middleImageView;
@property (nonatomic, strong) UIImageView *rightImageView;
@property (nonatomic, strong) LikeAndReplyButton *likeButton;
@property (nonatomic, strong) LikeAndReplyButton *replyButton;
@property (nonatomic, strong) UIButton *joinButton;
@property (nonatomic, strong) AssemblingPlaceView *assembleView;
@end

@implementation TravelTableCell

- (void)setTravelItem:(TravelItem *)travelItem {
    _travelItem = travelItem;
    [_headImage sd_setImageWithURL:[NSURL URLWithString:_travelItem.HeadUrl]];
    [_headImage sizeToFit];

    _nameLabel.text = _travelItem.Nickname;
    [_nameLabel sizeToFit];
    if ([travelItem.Gender isEqualToString:@"女"]) {
        _genderImage.image = [UIImage imageNamed:@"woman"];
        _genderImage.backgroundColor = [UIColor colorWithRed:0.929 green:0.478 blue:0.596 alpha:1.000];
        _ageLabel.backgroundColor = [UIColor colorWithRed:0.929 green:0.478 blue:0.596 alpha:1.000];
    } else {
        _genderImage.image = [UIImage imageNamed:@"man"];
        _genderImage.backgroundColor = [UIColor colorWithRed:0.525 green:0.675 blue:0.929 alpha:1.000];
        _ageLabel.backgroundColor = [UIColor colorWithRed:0.525 green:0.675 blue:0.929 alpha:1.000];
    }
    [_genderImage sizeToFit];
    
    _ageLabel.text = [NSString stringWithFormat:@"%zd岁", _travelItem.Age];
    [_ageLabel sizeToFit];
    _ageLabel.textColor = [UIColor whiteColor];
    _ageLabel.font = [UIFont systemFontOfSize:13.f];
    
    [self setUpTimeAndRangeLabel];
    
    _remarkLabel.text = _travelItem.Remark;
    _destinationLabel.text = _travelItem.Destination;
    [_destinationLabel sizeToFit];
    _requireLabel.text = _travelItem.Require;
    _moneyTypeLabel.text = _travelItem.MoneyType;
    [_moneyTypeLabel sizeToFit];
    NSArray<Piclist *> *picArray = _travelItem.PicList;
    if (picArray.count >= 1) {
        [_leftImageView sd_setImageWithURL:[NSURL URLWithString:picArray.firstObject.Url]];
        _leftImageView.clipsToBounds = YES;
        _leftImageView.contentMode = UIViewContentModeScaleAspectFill;
        _leftImageView.hidden = NO;
    } else {
        _leftImageView.hidden = YES;
        _middleImageView.hidden = YES;
        _rightImageView.hidden = YES;
    }
    if (picArray.count >= 2) {
        [_middleImageView sd_setImageWithURL:[NSURL URLWithString:picArray[1].Url]];
        _middleImageView.clipsToBounds = YES;
        _middleImageView.contentMode = UIViewContentModeScaleAspectFill;
    } else {
        _middleImageView.hidden = YES;
        _rightImageView.hidden = YES;
    }
    if (picArray.count >= 3) {
        [_rightImageView sd_setImageWithURL:[NSURL URLWithString:picArray[2].Url]];
        _rightImageView.clipsToBounds = YES;
        _rightImageView.contentMode = UIViewContentModeScaleAspectFill;
    } else {
        _rightImageView.hidden = YES;
    }
    
    if (_travelItem.AssemblingPlace.Address.length > 0) {
        _assembleView.hidden = NO;
        _assembleView.assemblePlace = _travelItem.AssemblingPlace;
    } else {
        _assembleView.hidden = YES;
    }
    [_assembleView sizeToFit];
    
    if (_travelItem.YueyouLikeCount > 0) {
        [_likeButton setTitle:[NSString stringWithFormat:@"%zd", _travelItem.YueyouLikeCount] forState:UIControlStateNormal];
    } else {
        [_likeButton setTitle:@"喜欢" forState:UIControlStateNormal];
    }
    if (_travelItem.IsLike == YES) {
        [_likeButton setImage:[UIImage imageNamed:@"travelLike_selected"] forState:UIControlStateNormal];
    } else {
        [_likeButton setImage:[UIImage imageNamed:@"travelLike"] forState:UIControlStateNormal];
    }
    
    if (_travelItem.YueyouReplyCount > 0) {
        [_replyButton setTitle:[NSString stringWithFormat:@"%zd", _travelItem.YueyouReplyCount] forState:UIControlStateNormal];
    } else {
        [_replyButton setTitle:@"评论" forState:UIControlStateNormal];
    }
    
}

- (void)setUpTimeAndRangeLabel {
    NSMutableString *labelTextString = [NSMutableString string];
    NSString *startDateString = _travelItem.StartDate;
    if ([[NSDate date] compareOtherDateString:startDateString] > 0) {
        [labelTextString appendString:@"已结束 | "];
    } else {
        [labelTextString appendString:@"进行中 | "];
    }
    
    // 5分钟以内是 片刻之前 xx分钟前 xx小时 xx天 xx周
    NSString *intervalString = [NSDate intervalStringFromDateString:_travelItem.Created];
    [labelTextString appendString:intervalString];
    
    if (_travelItem.Latitude == 0 && _travelItem.Longitude == 0) {
        [labelTextString appendFormat:@" | 0km"];
    } else {
        CLLocation *location = [[CLLocation alloc] initWithLatitude:_travelItem.Latitude longitude:_travelItem.Longitude];
        CLLocationDistance distance = [location distanceFromLocation:[MyLocation sharedMyLocation].location];
        [labelTextString appendFormat:@" | %.2fkm", distance / 1000.0];
    }
    
    _timeAndRangeLabel.font = [UIFont systemFontOfSize:12.f];
    _timeAndRangeLabel.textColor = [UIColor colorWithWhite:0.651 alpha:1.000];
    _timeAndRangeLabel.text = labelTextString;
    [_timeAndRangeLabel sizeToFit];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initLayout];
        
        UITapGestureRecognizer *tapLeftImage = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageAction:)];
        UITapGestureRecognizer *tapMiddleImage = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageAction:)];
        UITapGestureRecognizer *tapRightImage = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageAction:)];
        [_leftImageView addGestureRecognizer:tapLeftImage];
        [_rightImageView addGestureRecognizer:tapRightImage];
        [_middleImageView addGestureRecognizer:tapMiddleImage];
        _leftImageView.userInteractionEnabled = YES;
        _rightImageView.userInteractionEnabled = YES;
        _middleImageView.userInteractionEnabled = YES;
    }
    return self;
}

- (void)initLayout {
    _rootLayout = [MyRelativeLayout new];
    _rootLayout.topPadding = 5;
    _rootLayout.bottomPadding = 5;
    
    _rootLayout.widthDime.equalTo(self.contentView.widthDime);
    _rootLayout.wrapContentHeight = YES;
    [self.contentView addSubview:_rootLayout];
    
    _headImage = [UIImageView new];
    _headImage.widthDime.equalTo(_rootLayout.widthDime).multiply(1/7.0f).max(45);
    _headImage.heightDime.equalTo(_headImage.widthDime);
    _headImage.leftPos.equalTo(@10);
    _headImage.topPos.equalTo(@10);
    _headImage.viewLayoutCompleteBlock = ^(MyBaseLayout *layout, UIView *sbv) {
        sbv.layer.cornerRadius = sbv.frame.size.width / 2;
        sbv.layer.masksToBounds = YES;
    };
    UITapGestureRecognizer *tapHead = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapHead)];
    [_headImage addGestureRecognizer:tapHead];
    _headImage.userInteractionEnabled = YES;
    [_rootLayout addSubview:_headImage];
    
    _nameLabel = [UILabel new];
    _nameLabel.leftPos.equalTo(_headImage.rightPos).offset(15);
    _nameLabel.topPos.equalTo(_headImage.topPos);
    [_rootLayout addSubview:_nameLabel];
    
    _genderImage = [UIImageView new];
    _genderImage.centerYPos.equalTo(_nameLabel.centerYPos);
    _genderImage.leftPos.equalTo(_nameLabel.rightPos).offset(15);
    _genderImage.widthDime.equalTo(@18);
    _genderImage.heightDime.equalTo(@18);
    [_rootLayout addSubview:_genderImage];
    
    _ageLabel = [UILabel new];
    _ageLabel.topPos.equalTo(_genderImage.topPos);
    _ageLabel.bottomPos.equalTo(_genderImage.bottomPos);
    _ageLabel.leftPos.equalTo(_genderImage.rightPos);
    [_rootLayout addSubview:_ageLabel];
    
    _timeAndRangeLabel = [UILabel new];
    _timeAndRangeLabel.topPos.equalTo(_nameLabel.bottomPos).offset(10);
    _timeAndRangeLabel.leftPos.equalTo(_nameLabel.leftPos);
    [_rootLayout addSubview:_timeAndRangeLabel];
    
    _remarkLabel = [UILabel new];
    _remarkLabel.leftPos.equalTo(_headImage.leftPos);
    _remarkLabel.rightPos.equalTo(_rootLayout.rightPos);
    _remarkLabel.topPos.equalTo(_headImage.bottomPos).offset(15);
    _remarkLabel.numberOfLines = 0;
    _remarkLabel.flexedHeight = YES;
    [_rootLayout addSubview:_remarkLabel];
    
    
    _destinationLabel = [UILabel new];
    _destinationLabel.rightPos.equalTo(_rootLayout.rightPos);
    _destinationLabel.topPos.equalTo(_remarkLabel.bottomPos).offset(10);
    _destinationLabel.font = [UIFont systemFontOfSize:15];
    _destinationLabel.textColor = [UIColor colorWithRed:0.259 green:0.420 blue:0.627 alpha:1.000];
    [_rootLayout addSubview:_destinationLabel];
    
    _destinationDotImage = [UIImageView new];
    _destinationDotImage.image = [UIImage imageNamed:@"dot"];
    [_destinationDotImage sizeToFit];
    _destinationDotImage.leftPos.equalTo(_remarkLabel.leftPos);
    _destinationDotImage.centerYPos.equalTo(_destinationLabel.centerYPos);
    _destinationDotImage.widthDime.equalTo(@10);
    _destinationDotImage.heightDime.equalTo(_destinationDotImage.widthDime);
    [_rootLayout addSubview:_destinationDotImage];
    _destinationLabel.leftPos.equalTo(_destinationDotImage.rightPos).offset(5);
    
    _requireLabel = [UILabel new];
    _requireLabel.leftPos.equalTo(_destinationLabel.leftPos);
    _requireLabel.rightPos.equalTo(_rootLayout.rightPos);
    _requireLabel.topPos.equalTo(_destinationLabel.bottomPos).offset(10);
    _requireLabel.numberOfLines = 0;
    _requireLabel.flexedHeight = YES;
    _requireLabel.font = [UIFont systemFontOfSize:15];
    _requireLabel.textColor = [UIColor colorWithRed:0.259 green:0.420 blue:0.627 alpha:1.000];
    [_rootLayout addSubview:_requireLabel];
    
    _requireDotImage = [UIImageView new];
    _requireDotImage.image = [UIImage imageNamed:@"dot"];
    [_requireDotImage sizeToFit];
    _requireDotImage.leftPos.equalTo(_destinationDotImage.leftPos);
    _requireDotImage.topPos.equalTo(_requireLabel.topPos).offset(5);
    _requireDotImage.widthDime.equalTo(_destinationDotImage.widthDime);
    _requireDotImage.heightDime.equalTo(_requireDotImage.widthDime);
    [_rootLayout addSubview:_requireDotImage];
    
    _moneyTypeLabel = [UILabel new];
    _moneyTypeLabel.leftPos.equalTo(_requireLabel.leftPos);
    _moneyTypeLabel.topPos.equalTo(_requireLabel.bottomPos).offset(10);
    _moneyTypeLabel.font = [UIFont systemFontOfSize:15];
    _moneyTypeLabel.textColor = [UIColor colorWithRed:0.259 green:0.420 blue:0.627 alpha:1.000];
    [_rootLayout addSubview:_moneyTypeLabel];
    
    _moneyDotImage = [UIImageView new];
    _moneyDotImage.image = [UIImage imageNamed:@"dot"];
    [_moneyDotImage sizeToFit];
    _moneyDotImage.leftPos.equalTo(_requireDotImage.leftPos);
    _moneyDotImage.centerYPos.equalTo(_moneyTypeLabel.centerYPos);
    _moneyDotImage.widthDime.equalTo(_destinationDotImage.widthDime);
    _moneyDotImage.heightDime.equalTo(_moneyDotImage.widthDime);
    [_rootLayout addSubview:_moneyDotImage];
    
    _leftImageView = [UIImageView new];
    _leftImageView.heightDime.equalTo(_leftImageView.widthDime);
    _leftImageView.topPos.equalTo(_moneyTypeLabel.bottomPos).offset(10);
    _leftImageView.leftPos.equalTo(_headImage.leftPos);
    [_rootLayout addSubview:_leftImageView];
    
    _middleImageView = [UIImageView new];
    _middleImageView.widthDime.equalTo(_leftImageView.widthDime);
    _middleImageView.heightDime.equalTo(_middleImageView.widthDime);
    _middleImageView.topPos.equalTo(_leftImageView.topPos);
    _middleImageView.leftPos.equalTo(_leftImageView.rightPos).offset(10);
    [_rootLayout addSubview:_middleImageView];
    
    _rightImageView = [UIImageView new];
    _rightImageView.widthDime.equalTo(_leftImageView.widthDime);
    _rightImageView.heightDime.equalTo(_rightImageView.widthDime);
    _rightImageView.topPos.equalTo(_leftImageView.topPos);
    _rightImageView.leftPos.equalTo(_middleImageView.rightPos).offset(10);
    [_rootLayout addSubview:_rightImageView];
    
    _leftImageView.widthDime.equalTo(@[_middleImageView.widthDime.add(-10), _rightImageView.widthDime.add(-10)]).add(-20);

    _assembleView = [AssemblingPlaceView new];
    _assembleView.topPos.equalTo(_leftImageView.bottomPos).offset(10);
    _assembleView.leftPos.equalTo(_leftImageView.leftPos);
    _assembleView.rightPos.equalTo(_rootLayout.rightPos).offset(10);
    _assembleView.heightDime.equalTo(@80);
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(assembleViewTap)];
    [_assembleView addGestureRecognizer:tap];
    [_rootLayout addSubview:_assembleView];
    
    _likeButton = [LikeAndReplyButton new];
    [_likeButton setTitleColor:[UIColor colorWithWhite:0.486 alpha:1.000] forState:UIControlStateNormal];
//    [_likeButton setImage:[UIImage imageNamed:@"travelLike"] forState:UIControlStateNormal];
    _likeButton.titleLabel.font = [UIFont systemFontOfSize:15.f];
    _likeButton.topPos.equalTo(_assembleView.bottomPos).offset(10);
    _likeButton.leftPos.equalTo(_rootLayout.leftPos);
    _likeButton.widthDime.equalTo(_rootLayout.widthDime).multiply(1/3.0);
    _likeButton.heightDime.equalTo(@40);
    [_rootLayout addSubview:_likeButton];
    
    _replyButton = [LikeAndReplyButton new];
    [_replyButton setTitleColor:[UIColor colorWithWhite:0.486 alpha:1.000] forState:UIControlStateNormal];
    [_replyButton setImage:[UIImage imageNamed:@"travelComment"] forState:UIControlStateNormal];
    _replyButton.titleLabel.font = [UIFont systemFontOfSize:15.f];
    _replyButton.leftPos.equalTo(_likeButton.rightPos);
    _replyButton.topPos.equalTo(_likeButton.topPos);
    _replyButton.widthDime.equalTo(_likeButton.widthDime);
    _replyButton.heightDime.equalTo(_likeButton.heightDime);
    [_rootLayout addSubview:_replyButton];
    
    _joinButton = [UIButton new];
    [_joinButton setTitle:@"入伙" forState:UIControlStateNormal];
    [_joinButton setTitleColor:[UIColor colorWithWhite:0.486 alpha:1.000] forState:UIControlStateNormal];
    _joinButton.titleLabel.font = [UIFont systemFontOfSize:15.f];
    _joinButton.leftPos.equalTo(_replyButton.rightPos);
    _joinButton.rightPos.equalTo(_rootLayout.rightPos);
    _joinButton.topPos.equalTo(_replyButton.topPos);
    _joinButton.heightDime.equalTo(_replyButton.heightDime);
    [_rootLayout addSubview:_joinButton];
    
    
    UIView *backView = [UIView new];
    backView.backgroundColor = [UIColor colorWithWhite:0.922 alpha:1.000];
    backView.leftPos.equalTo(_rootLayout.leftPos);
    backView.rightPos.equalTo(_rootLayout.rightPos);
    backView.bottomPos.equalTo(_likeButton.topPos);
    backView.heightDime.equalTo(@1);
    [_rootLayout addSubview:backView];
    
    UIView *leftGrayView = [UIView new];
    leftGrayView.backgroundColor = [UIColor colorWithWhite:0.922 alpha:1.000];
    leftGrayView.centerYPos.equalTo(_likeButton.centerYPos);
    leftGrayView.leftPos.equalTo(_likeButton.rightPos);
    leftGrayView.widthDime.equalTo(@1);
    leftGrayView.heightDime.equalTo(@20);
    [_rootLayout addSubview:leftGrayView];
    
    UIView *rightGrayView = [UIView new];
    rightGrayView.backgroundColor = [UIColor colorWithWhite:0.922 alpha:1.000];
    rightGrayView.centerYPos.equalTo(_likeButton.centerYPos);
    rightGrayView.rightPos.equalTo(_joinButton.leftPos);
    rightGrayView.widthDime.equalTo(leftGrayView.widthDime);
    rightGrayView.heightDime.equalTo(leftGrayView.heightDime);
    [_rootLayout addSubview:rightGrayView];
    
    // like reply join Button Action
    [_likeButton addTarget:self action:@selector(lrjAction:) forControlEvents:UIControlEventTouchUpInside];
    [_replyButton addTarget:self action:@selector(lrjAction:) forControlEvents:UIControlEventTouchUpInside];
    [_joinButton addTarget:self action:@selector(lrjAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)tapHead {
    [self.delegate sendUid:_travelItem.Uid];
}

- (void)tapImageAction:(UITapGestureRecognizer *)tap {
    UIImageView *imageView = (UIImageView *)tap.view;
    NSArray<Piclist *> *picArray = _travelItem.PicList;
    NSInteger currentImageIndex;
    if (imageView == _leftImageView) {
        currentImageIndex = 0;
    } else if (imageView == _middleImageView) {
        currentImageIndex = 1;
    } else if (imageView == _rightImageView) {
        currentImageIndex = 2;
    }
    
    NSDictionary *dic = @{@"picArray": picArray, @"currentImageIndex": @(currentImageIndex)};
    if ([self.delegate respondsToSelector:@selector(sendPicArrayAndImageUrl:)] && currentImageIndex < picArray.count) {
        [self.delegate sendPicArrayAndImageUrl:dic];
    }   
}

- (void)assembleViewTap {
    NSLog(@"点击集合地");
}

- (void)lrjAction:(UIButton *)button {
    BOOL isLogin = [[NSUserDefaults standardUserDefaults] boolForKey:@"isLogin"];    
    if (!isLogin) {
        [self.delegate sendLRJMsgDic:@{@"Msg":@"not Login"}];
    } else {
        if (button == _likeButton) {
            [self likeButtonClick];
        } else if (button == _replyButton) {
            NSDictionary *dic = @{@"Msg":@"reply", @"yid":@(_travelItem.Yid).stringValue};
            [self.delegate sendLRJMsgDic:dic];
        } else if (button == _joinButton) {
//            [self.delegate sendLRJMsgDic:@"join"];
        }
    }
}

- (void)likeButtonClick {
    NSString *tocken = [[NSUserDefaults standardUserDefaults] objectForKey:@"tocken"];
    if (tocken.length == 0) {
        tocken = @"";
    }
    NSDictionary *headerDic = @{@"Content-Length":@"52", @"Content-Type":@"application/x-www-form-urlencoded", @"Host":@"api.miaotu.net", @"Connection":@"Keep-Alive", @"User-Agent":@"Apache-HttpClient/UNAVAILABLE (java 1.4) Paros/3.2.13"};
    NSString *body = [NSString stringWithFormat:@"token=%@&yid=%zd", tocken, _travelItem.Yid];
    [ZWYNetTool POST:@"http://api.miaotu.net/v2/yueyou/like" andBody:body andBodyStyle:ZWYBodyString andHeader:headerDic andResponse:ZWYJSON andSuccessBlock:^(id result) {
        LikeModel *likeModel = [LikeModel modelWithDic:result];
        [self resetLikeButton:likeModel.Items.Ylid];
    } andFailureBlock:^(NSError *error) {
        
    }];
}

- (void)resetLikeButton:(NSInteger)ylid {
    NSString *likeMsg = nil;
    if (ylid == 0) {
        likeMsg = @"取消喜欢";
        if (_likeButton.titleLabel.text.integerValue == 1) {
            [_likeButton setTitle:@"喜欢" forState:UIControlStateNormal];
            _travelItem.YueyouLikeCount = 0;
        } else {
            [_likeButton setTitle:@(_likeButton.titleLabel.text.integerValue - 1).stringValue forState:UIControlStateNormal];
            _travelItem.YueyouLikeCount = _likeButton.titleLabel.text.integerValue - 1;
        }
        [_likeButton setImage:[UIImage imageNamed:@"travelLike"] forState:UIControlStateNormal];
        _travelItem.IsLike = NO;
        if ([_likeButton.titleLabel.text isEqualToString:@"喜欢"]) {
            _travelItem.YueyouLikeCount = 0;
        } else {
            _travelItem.YueyouLikeCount = _likeButton.titleLabel.text.integerValue;
        }
    } else {
        likeMsg = @"喜欢成功";
        if ([_likeButton.titleLabel.text isEqualToString:@"喜欢"]) {
            [_likeButton setTitle:@"1" forState:UIControlStateNormal];
        } else {
            NSInteger likeCount = _likeButton.titleLabel.text.integerValue + 1;
            [_likeButton setTitle:@(likeCount).stringValue forState:UIControlStateNormal];
        }
        [_likeButton setImage:[UIImage imageNamed:@"travelLike_selected"] forState:UIControlStateNormal];
        _travelItem.IsLike = YES;
        _travelItem.YueyouLikeCount = _likeButton.titleLabel.text.integerValue;
    }
    [self.delegate sendLRJMsgDic:@{@"Msg":likeMsg}];
}

- (void)prepareForReuse {
    [super prepareForReuse];
    if (_travelItem.YueyouLikeCount > 0) {
        [_likeButton setTitle:[NSString stringWithFormat:@"%zd", _travelItem.YueyouLikeCount] forState:UIControlStateNormal];
    } else {
        [_likeButton setTitle:@"喜欢" forState:UIControlStateNormal];
    }
    if (_travelItem.IsLike == YES) {
        [_likeButton setImage:[UIImage imageNamed:@"travelLike_selected"] forState:UIControlStateNormal];
    } else {
        [_likeButton setImage:[UIImage imageNamed:@"travelLike"] forState:UIControlStateNormal];
    }
}

- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
